# -*- coding: utf-8 -*-
# Django settings for pygameweb project.
import os

DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = os.path.join(
                   os.path.dirname(os.path.abspath(__file__)),
                    'dev.db')   # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'

# for datetimes in the admin, used by djangos time formatting
# see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ttag-now
DATETIME_FORMAT = 'M d, P T'

# for datetimes on the site, used with time.strftime
SITE_DATETIME_FORMAT = '%d %B %Y, %I:%M %p %Z'


# timezone choices for profile fields
# list of (timezone, human-readable-string) tuples
import pytz, datetime
TIMEZONE_CHOICES = []
for tz in pytz.common_timezones:
    now = datetime.datetime.now(pytz.timezone(tz))
    TIMEZONE_CHOICES.append((tz, "%s %s" % (tz,
                                            now.strftime("%X (%Z / GTM%z)"))))

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "media")

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = "/media/"

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/admin/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = ''

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    'pygameweb.notification.middleware.SubscriptionHandler',
    'pygameweb.utils.middleware.StatusMiddleware',
    
)

ROOT_URLCONF = 'pygameweb.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates"),
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.core.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",    
    "projects.context_processors.recent_releases",
    "utils.context_processors.settings",
    "utils.context_processors.users_online",
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.flatpages',
    'tagging',
    'haystack',
    'pygameweb.news',
    'pygameweb.projects',
    'pygameweb.comments',
    'pygameweb.registration',
    'pygameweb.profiles',
    'pygameweb.utils',
    'pygameweb.notification',
    'pygameweb.cab',
)

EMAIL_HOST = ""
EMAIL_HOST_USER = ""
EMAIL_HOST_PASSWORD = ""
#EMAIL_USE_TLS = True
#EMAIL_PORT = 465

DEFAULT_FROM_EMAIL = ""

AUTH_PROFILE_MODULE = "profiles.Profile"

LOGIN_REDIRECT_URL = "/profiles/edit/"

ABSOLUTE_URL_OVERRIDES = {
    'auth.user': lambda u: "/profiles/%s/" % u,
}


################
# own settings #
################

# news per page on news overview
NEWS_PER_PAGE = 5

NEWS_TRUNCATE_WORDS = 100

PROFILES_PER_PAGE = 25

# projects on overview page
PROJECTS_PER_PAGE = 10

SNIPPETS_PER_PAGE = 20

PROJECT_TRUNCATE_WORDS = 75

# number of recent releases shown in the sidebar
SHOW_RECENT_RELEASES = 8

# relative to media_root, used for projects without screenshot
DUMMY_SCREENSHOT_PATH = "screenshots/dummy.png"

# css themes
# first value: name of the css file (without ext); max 8 chars
# second value: human readable name/description
# default will be wrapped to current default theme
THEMES = (
    ("default", "Default"),
    ("modern", "Modern"),
    ("classic", "Classic"),
)
# default theme (name of css file without ext)
DEFAULT_THEME = "modern"

# default pygments style, must be in pygments.styles.get_all_styles()
DEFAULT_STYLE = "friendly"

# users that requested a site within the last X minutes will be
# assumed to be online
MINUTES_UNTIL_OFFLINE = 5

RECENT_SNIPPETS_FEED_OBJECTS = 10
RECENT_RELEASES_FEED_OBJECTS = 10
RECENT_NEWS_FEED_OBJECTS = 4

POTM_FEED_OBJECTS = 4

COMMENTS_PER_FEED = 10

SYS_USERNAME = "_sys_"

#
# ircbot
#
BOT_ENABLE = False # try to send notifications to the bot
BOT_SEND_NEWS = True 
BOT_SET_TITLE = True # update irc channel titles to news
BOT_TITLE_REGEX = "(\\| latest news: )(?:.*?)()$" # used to update news in titles
BOT_SEND_RELEASES = True 
BOT_SEND_SNIPPETS = True

BOT_NICK = "bt"
BOT_IP = "irc.freenode.net"
BOT_PORT = 6667
# list of channel names the bot will enter (will be prefixed with a '#')
BOT_CHANNELS = ("bottest","bot_test")
# message to send after joining a channel
BOT_ENTER_MSG = ""

#
# registration 
#
# how long an account activation or email confirmation is valid
ACCOUNT_ACTIVATION_DAYS = 3


#
# tagging
#
FORCE_LOWERCASE_TAGS = True
MAX_TAG_LENGTH = 50

# own tagging options
# minimum no of usage to display a tag in a tag-list
MIN_COUNT = 3

#
# piston (REST api)
#
PISTON_EMAIL_ERRORS = True
PISTON_DISPLAY_ERRORS = True

#
# haystack (searching)
#

HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'xapian'
HAYSTACK_XAPIAN_PATH = 'search_index'
#
## "place on your filesystem where the Whoosh index should be located. 
##  Standard warnings about permissions and keeping it out of a place 
##  your webserver may serve documents out of apply."
#HAYSTACK_WHOOSH_PATH = 'search_index'
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 5



try:
    from localsettings import *
except ImportError:
    pass
